flutter if else

55

Container(
  color: Colors.white,
  child: ('condition')
  ? Widget1(...)
  : Widget2(...)
)
it will work inside an widget.
Column(
  children: [ 
    if(a > 10)...[
      Text("A is greater than 10"),
    ]else...[
      Text("A is less than or Equal to 10")
    ]
])

Normally:
    int time = 6;
    if(time > 12) {
      time = time - 12;
      print('$time PM');
    }else {
      print('$time AM');
    };
condition? Text("True"): null,
(() {
  // your code here
}())
void main() { 
   var num = 12; 
   if (num % 2==0) { 
      print("Even"); 
   } else { 
      print("Odd"); 
   } 
}

Comments

Submit
0 Comments